//
//  aboutUsSwiftVC.swift
//  UIScrollView的快速使用
//
//  Created by hongfei tam on 2018/12/23.
//  Copyright © 2018 YQ05. All rights reserved.
//


import UIKit



class aboutUsSwiftVC: UIViewController {
    
    let scrollView=UIScrollView()
    //let title_label = UILabel()

    override func viewDidLoad() {
        super.viewDidLoad()
        //view.backgroundColor = UIColor.white;
        view.backgroundColor = UIColor(valueRGB: 0xf2f2f2, alpha: 1.0) //直接输入16进制颜色
        
        //scrollView.frame=self.view.bounds
        scrollView.frame = CGRect(x: 0, y: 0, width: UISCREEN_WIDTH, height: UISCREEN_HEIGHT)
            //        let imageView=UIImageView(image:UIImage(named:"1"))
        scrollView.contentSize=CGSize(width: UISCREEN_WIDTH, height: 700);
            //        scrollView.addSubview(imageView);
           // self.navigationController?.hidesBarsOnSwipe = true //隐藏导航栏
//        scrollview?.maximumZoomScale = 2.0 //最小比例
//        scrollview?.minimumZoomScale = 0.5  //最大比例
//        scrollview?.canCancelContentTouches = false
        //当值是 YES的时候，用户触碰开始.要延迟一会，看看是否用户有意图滚动。假如滚动了，那么捕捉 touch-down事件，否则就不捕捉。假如值是NO，当用户触碰， scroll view会立即触发
//        scrollview.delaysContentTouches = true
//        //分页滑动
//        self.scrollview?.pagingEnabled = true
//        //开启滚动
//        self.scrollview?.scrollEnabled = true
//        //滚动时是否显示水平滚动条
//        self.scrollView?.showsHorizontalScrollIndicator = false
        //滚动时是否显示垂直滚动条
        scrollView.showsVerticalScrollIndicator = false
        //是否加反弹效果
        scrollView.bounces = false
        //滚动条的样式
        //scrollView.indicatorStyle = .black //Black:黑色；Default默认；White白色
        
        
            self.view.addSubview(scrollView)
        //self.viewtest()
        
        titleLabel()
        //self.img()
        //h3titleLabel()
        //contentLabel()
        //save()
        // Do any additional setup after loading the view.
    }
    
    func viewtest()  {
        let testView = UIView(frame: CGRect(x: 50, y: 100, width: 200, height: 200))
        let testView2 = UIView(frame: CGRect(x: 50, y: 100, width: 200, height: 200))
        testView.backgroundColor = UIColor.red
        testView.tag = 1
        testView.isUserInteractionEnabled =   true
        
        
        testView2.backgroundColor = UIColor.blue
        testView2.tag = 2
        view.addSubview(testView2)
        view.addSubview(testView)
        
        let tap1 = UITapGestureRecognizer(target: self, action: #selector(handleTap1))
        
        let tap2 = UITapGestureRecognizer(target: self, action: #selector(handleTap2))
        
        testView.addGestureRecognizer(tap1)
        testView2.addGestureRecognizer(tap2)
        
        for subView in view.subviews {
            if subView.tag == 1 {
                print(subView.frame)
            }
        }
    }
    
    @objc func handleTap1() {
        //view.insertSubview(testView, belowSubview: testView2)
    }
    
    @objc func handleTap2() {
        
    }
    
    @objc func titleLabel() {
        let label_title = UILabel()
        label_title.frame = CGRect(x: 40, y: 30, width: UISCREEN_WIDTH - 80, height: 30)
        label_title.font = UIFont.systemFont(ofSize: 22)
        label_title.textColor = (UIColor(red: 117.0/255.0, green: 76.0/255.0, blue: 36.0/255.0, alpha: 1.0))//UIColor.blue 117,76,36  //#754c24;
        label_title.textAlignment = .center
        //label_title.backgroundColor = UIColor.black
        label_title.text = "關於Young+"
        label_title.numberOfLines = 0
        label_title.lineBreakMode = .byCharWrapping
        
        //label_title.font = UIFont.systemFontOfSize(30.px)  //设置行间距
        label_title.font = UIFont.systemFont(ofSize: 26) //字体大小
        //label_title.sizeToFit()  //适应大小
        _ = label_title.frame.height
        //let tap = UITapGestureRecognizer(target: self, action: #selector(changeTextContent))
        //label_title.addGestureRecognizer(tap)
        label_title.isUserInteractionEnabled = true
        scrollView.addSubview(label_title)
//    }
//
//    @objc func img(){
        //let imageView = UIImageView(frame: CGRect(x:  20, y: 80, width: UISCREEN_WIDTH - 40, height: ((UISCREEN_WIDTH - 40) * 0.543)))
        let imageView = UIImageView(frame: CGRect(x:  20, y: label_title.frame.origin.y+30+20, width: UISCREEN_WIDTH - 40, height: ((UISCREEN_WIDTH - 40) * 0.543)))
        //bt_login.frame.origin.y+bt_login.frame.size.height+10
        //imageView.backgroundColor = UIColor.red
        imageView.image = UIImage(named: "pic_about_460x250.png")
        //imageView.animationImages = [UIImage(named: "pic1.JPG")!, UIImage(named: "pic2.JPG")!]
        //        imageView.animationDuration = 1
        //        imageView.animationRepeatCount = 100
        scrollView.addSubview(imageView)
//    }
//
//    @objc func h3titleLabel() {
        let label_h3titleLabel = UILabel()
        label_h3titleLabel.frame = CGRect(x: 40/2, y: imageView.frame.origin.y+imageView.frame.size.height+40, width: UISCREEN_WIDTH - 40, height: 30)
        label_h3titleLabel.font = UIFont.systemFont(ofSize: 22)
        label_h3titleLabel.textColor = (UIColor(red: 51.0/255.0, green: 51.0/255.0, blue: 51.0/255.0, alpha: 1.0))//UIColor.blue 117,76,36  //#333;;
        label_h3titleLabel.textAlignment = .left
        //label_title.backgroundColor = UIColor.black
        label_h3titleLabel.text = "品牌理念Young+ Mission:"
        label_h3titleLabel.numberOfLines = 0
        label_h3titleLabel.lineBreakMode = .byCharWrapping
        label_h3titleLabel.font = UIFont.systemFont(ofSize: 24) //字体大小
        //label_title.sizeToFit()  //适应大小
        _ = label_h3titleLabel.frame.height
        //let tap = UITapGestureRecognizer(target: self, action: #selector(changeTextContent))
        //label_title.addGestureRecognizer(tap)
        //label_h2titleLabel.isUserInteractionEnabled = true //可点击
        scrollView.addSubview(label_h3titleLabel)
//    }
//
//    @objc func contentLabel() {
        let label = UILabel()
        label.frame = CGRect(x: 20, y: label_h3titleLabel.frame.origin.y+50+5, width: UISCREEN_WIDTH - 40, height: 400)
        label.font = UIFont.systemFont(ofSize: 18)
        label.textColor = (UIColor(red: 51.0/255.0, green: 51.0/255.0, blue: 51.0/255.0, alpha: 1.0))
        label.textAlignment = .left
        //label.backgroundColor = UIColor.red
        //label.text = "Young+ 透過高科技醫學檢測及專業數據分析為客戶進行全方位個人化健康評估，結合中西方醫學、營養監控、皮膚及體重管理等專業服務, 致誠為顧客提供一站式健康管理服務, 透過精準醫學數據及先進科學數碼化的監察, 時刻為客戶貼心跟進身體狀態, 全面照顧所需, 推動逆齡健康生活, 從內而外散發身心年輕自信魅力, 享受優越理想生活模式。"
        let str = "Young+ 透過高科技醫學檢測及專業數據分析為客戶進行全方位個人化健康評估，結合中西方醫學、營養監控、皮膚及體重管理等專業服務, 致誠為顧客提供一站式健康管理服務, 透過精準醫學數據及先進科學數碼化的監察, 時刻為客戶貼心跟進身體狀態, 全面照顧所需, 推動逆齡健康生活, 從內而外散發身心年輕自信魅力, 享受優越理想生活模式。"
        //通过富文本来设置行间距
        let paraph = NSMutableParagraphStyle()
        //将行间距设置为28
        paraph.lineSpacing = 14
        //样式属性集合
        let attributes = [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 15),
                          NSAttributedString.Key.paragraphStyle: paraph]
        label.attributedText = NSAttributedString(string: str, attributes: attributes)
        
        label.numberOfLines = 0
        label.lineBreakMode = .byWordWrapping
        label.sizeToFit() //自动计算label高度
        label.adjustsFontSizeToFitWidth = true //当文字超出标签宽度时，自动调整文字大小，使其不被截断
        _ = label.frame.height
        //let tap = UITapGestureRecognizer(target: self, action: #selector(changeTextContent))
        //label.addGestureRecognizer(tap)
        //label.isUserInteractionEnabled = true
        scrollView.addSubview(label)
    }
    

    

    
//    func save()  {
//        //设置存储信息
//        let userDefault = UserDefaults.standard
//        //NSString类型
//        userDefault.set("banner1", forKey: "NSString")
//        //_ = userDefault.object(forKey: "NSString") as! NSString
//
//        //        UserDefaults.standardUserDefaults.setObject(nameField.text, forKey: "UserNameKey")
//        //        UserDefaults.standardUserDefault.setObject(self.pwdField.text, forKey: "PwdKey")
//        //        UserDefaults.standardUserDefaults().setBool(self.rembSwich.on, forKey: "RmbPwdKey")
//        //设置同步
//        UserDefaults.standard.synchronize()
//
//
//        let swstr = userDefault.object(forKey: "NSString") as! NSString  //swift 读取
//
//        print("点击了显示评论按钮",swstr)
//    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

/**
 *  扩展部分
 */

